#ifndef PLAYER_H
#define PLAYER_H

#include "main.h"

#define STAYING 0
#define PLAYING 1
#define UNKNOWN 2

class GameRoom;

class Player {
public:
    Player(string id, websocketpp::connection_hdl h) : uid(id), hdl(h), room(nullptr), state(STAYING), isReady(false), name("New Player") {}
    ~Player();
    void sleep();
    void recovery(const websocketpp::connection_hdl& h);
    ErrorType setPlayer(Json::Value& set);

    websocketpp::connection_hdl getHdl(){
        return hdl;
    }
    string getUid(){
        return uid;
    }
    Json::Value getSet(){
        Json::Value set;
        set["uuid"] = uid;
        set["name"] = name;
        set["icon"] = static_cast<int>(icon);
        set["ready"] = isReady;
        return set;
    }
    GameRoom* getRoom(){
        return room;
    }
    int getState(){
        return state;
    }

    enum ICON{
        RED,
        GREEN,
        PURPLE,
        BLUE,
        YELLOW
    } icon;
    ErrorType exit();
    ErrorType joinGame(GameRoom* gameRoom);
    //bool joinGame(string rid);

    ErrorType ready();
    ErrorType unready();
private:
	string uid;
    string name;

    GameRoom* room;
    int state;
    websocketpp::connection_hdl hdl;
    bool isReady;
};

#endif // !PLAYER_H

